package threading;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Microsoft
 * Date: 2023-07-05
 * Time: 15:12
 */
public class ThreadDemo7 {
    public static void main(String[] args) {
        Thread thread = new Thread(() -> {
            System.out.println("hello thread");
        });

        thread.start();

        try {
            //上述t线程没有进行任何的循环和sleep，意味着里面的代码会迅速执行完毕
            //main线程中如果sleep方法结束，此时thread基本上就是已经执行完的状态，此时thread对象还在
            //但是在系统中，对应的线程已经结束了
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println(thread.isAlive());//判断线程是否执行结束
    }
}
